(function(){"use strict";BX.namespace("BX.Landing.UI.Tool");BX.Landing.UI.Tool.ColorPicker=function(e,t){this.picker=new BX.ColorPicker({bindElement:e.layout,popupOptions:BX.Landing.UI.Tool.ColorPicker.getDefaultPopupOptions(e),onColorSelected:BX.delegate(this.onColorSelected,this),colors:BX.Landing.UI.Tool.ColorPicker.getDefaultColors()});this.button=e;this.onChangeHandler=t;this.pickerWindow=this.picker.getPopupWindow();this.contextDocument=document;this.range=this.contextDocument.createRange();BX.Landing.UI.Tool.ColorPicker.activePickers.add(this)};BX.Landing.UI.Tool.ColorPicker.getDefaultPopupOptions=function(e){return{angle:false,position:{top:0,left:0},zIndex:-678,overlay:{backgroundColor:"#ffffff",opacity:10}}};BX.Landing.UI.Tool.ColorPicker.activePickers=new BX.Landing.Collection.BaseCollection;BX.Landing.UI.Tool.ColorPicker.hideAll=function(){BX.Landing.UI.Tool.ColorPicker.activePickers.forEach((function(e){e.hide()}))};BX.Landing.UI.Tool.ColorPicker.getDefaultColors=function(){return[["#f5f5f5","#eeeeee","#e0e0e0","#9e9e9e","#757575","#616161","#212121"],["#cfd8dc","#b0bec5","#90a4ae","#607d8b","#546e7a","#455a64","#263238"],["#d7ccc8","#bcaaa4","#a1887f","#795548","#6d4c41","#5d4037","#3e2723"],["#ffccbc","#ffab91","#ff8a65","#ff5722","#f4511e","#e64a19","#bf360c"],["#ffe0b2","#ffcc80","#ffb74d","#ff9800","#fb8c00","#f57c00","#e65100"],["#ffecb3","#ffe082","#ffd54f","#ffc107","#ffb300","#ffa000","#ff6f00"],["#fff9c4","#fff59d","#fff176","#ffeb3b","#fdd835","#fbc02d","#f57f17"],["#f0f4c3","#e6ee9c","#dce775","#cddc39","#c0ca33","#afb42b","#827717"],["#dcedc8","#c5e1a5","#aed581","#8bc34a","#7cb342","#689f38","#33691e"],["#c8e6c9","#a5d6a7","#81c784","#4caf50","#43a047","#388e3c","#1b5e20"],["#b2dfdb","#80cbc4","#4db6ac","#009688","#00897b","#00796b","#004d40"],["#b2ebf2","#80deea","#4dd0e1","#00bcd4","#00acc1","#0097a7","#006064"],["#b3e5fc","#81d4fa","#4fc3f7","#03a9f4","#039be5","#0288d1","#01579b"],["#bbdefb","#90caf9","#64b5f6","#2196f3","#1e88e5","#1976d2","#0d47a1"],["#c5cae9","#9fa8da","#7986cb","#3f51b5","#3949ab","#303f9f","#1a237e"],["#d1c4e9","#b39ddb","#9575cd","#673ab7","#5e35b1","#512da8","#311b92"],["#e1bee7","#ce93d8","#ba68c8","#9c27b0","#8e24aa","#7b1fa2","#4a148c"],["#f8bbd0","#f48fb1","#f06292","#e91e63","#d81b60","#c2185b","#880e4f"],["#ffcdd2","#ef9a9a","#e57373","#f44336","#e53935","#d32f2f","#b71c1c"]].map((function(e,t,o){return o.map((function(e){return e[t]}))}))};BX.Landing.UI.Tool.ColorPicker.prototype={adjustPosition:function(e){BX.DOM.read(function(){var t=this.pickerWindow.popupContainer.getBoundingClientRect();var o=this.button.layout.parentNode.getBoundingClientRect();var n=Math.abs(t.width-o.width);var i={};i["left"]=o.left+n/2+"px";i["position"]="fixed";if(e==="fixed"){var c=this.button.layout.getBoundingClientRect();i["top"]=c.bottom+"px"}else{var f=BX.pos(this.button.layout);i["top"]=f.bottom+"px"}if(BX.Landing.Main.getInstance().isControlsExternal()){i["left"]="3px";i["height"]="210px"}BX.DOM.write(function(){for(var e in i){this.pickerWindow.popupContainer.style[e]=i[e]}}.bind(this))}.bind(this))},show:function(e){this.picker.open();this.adjustPosition(e);this.range=this.contextDocument.getSelection().getRangeAt(0)},hide:function(){this.picker.close()},isShown:function(){return this.pickerWindow.isShown()},onColorSelected:function(e,t){this.contextDocument.getSelection().removeAllRanges();this.contextDocument.getSelection().addRange(this.range);if(BX.type.isFunction(this.onChangeHandler)){this.onChangeHandler(e,t)}},setContextDocument:function(e){if(e.nodeType===Node.DOCUMENT_NODE){this.contextDocument=e;if(!this.isShown()){this.range=this.contextDocument.createRange()}}}}})();
//# sourceMappingURL=color_picker.map.js